﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.Tests.Integration.Instruments
{
    public class AssertionHelper<TPackage>
        where TPackage : Package
    {
        public void Fail()
        {
            Assert.Fail();
        }

        public void ObjectsAreEqual<T>(T expected, T actual)
        {
            Assert.AreEqual<T>(expected, actual);
        }

        public void CollectionsAreEqual<T>(IEnumerable<T> expected, IEnumerable<T> actual)
        {
            CollectionAssert.AreEqual(expected.ToList(), actual.ToList());
        }

        public void WindowPaneExists<TWindowPane>()
            where TWindowPane : ToolWindowPane
        {
            var manager = new WindowPaneManager<TPackage>();
            Assert.IsTrue(manager.Exists<TWindowPane>(), "The window pane ({0}) wasn't found.", typeof(TWindowPane).FullName);
        }

        public void WindowPaneDoesNotExist<TWindowPane>()
            where TWindowPane : ToolWindowPane
        {
            var manager = new WindowPaneManager<TPackage>();
            Assert.IsFalse(manager.Exists<TWindowPane>(), "The window pane ({0}) had already opened.", typeof(TWindowPane).FullName);
        }
    }
}
